export default {
    state: {
    //   user: "", // 登录的用户
      showLogin: false, // 用于控制是否显示登录组件
      userinfo: ""
    },
    getters: {
      getUser (state) {
        return state.userinfo
      },
      getShowLogin (state) {
        return state.showLogin
      }
    },
    //修改状态的地方,同步
    mutations: {
    //   setUser (state, data) {
    //     state.user = data;
    //   },
      setShowLogin (state, data) {
        state.showLogin = data;
      },
       //设置用户登录信息
      setUser(state,user){
        console.log("user:",user)
        // localStorage.setItem('user',JSON.stringify(user))
        state.userinfo = user
      }
    },
    //修改状态的地方,异步
    actions: {
      setUser ({ commit }, data) {
        commit('setUser', data);
      },
      setShowLogin ({ commit }, data) {
        commit('setShowLogin', data);
      }
    }
  }